package com.example.modelviewpresenter.View;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.modelviewpresenter.Presenter.InitPresenter;

public abstract class BasterFragment <Presenter extends InitPresenter> extends Fragment implements InitFragment,InitView {

    protected Presenter presenter;
    private View view;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return view = inflater.inflate(BandLayout(),container,false);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initView();
        initDate();
    }

    @Override
    public void ShowLayout() {

    }

    @Override
    public void HaidLayout() {

    }

    @Override
    public void TostLayout(Context context, String name) {
        Toast.makeText(context,name,Toast.LENGTH_SHORT).show();
    }

    @Override
    public <T extends View> T findViewById(int id) {
        return view.findViewById(id);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (presenter!=null)
        {
            presenter=null;
            presenter.DiterPresenter();
        }
    }
}
